package com.vdg.fps.data;

import java.io.Serializable;
import java.util.List;


public class Member implements Serializable, Comparable<Member> {
	protected String mID;
	protected String mName;
	private boolean mIsAdmin;

	public String getID() {
		return mID;
	}

	public void setID(String mID) {
		this.mID = mID;
	}

	public String getName() {
		return mName;
	}

	public void setName(String mName) {
		this.mName = mName;
	}

	public boolean isIsAdmin() {
		return mIsAdmin;
	}

	public void setIsAdmin(boolean mIsAdmin) {
		this.mIsAdmin = mIsAdmin;
	}

	public Member(String id, String name) {
		this.mID = id;
		this.mName = name;
	}

	public Member(String id, String name, boolean admin) {
		this.mID = id;
		this.mName = name;
		this.mIsAdmin = admin;
	}

	public String toString() {
		return mID + "|" + mName;
	}

	public static String toString(List<Member> datas) {
		String result = "";
		if (datas == null || datas.size() == 0) {
		} else {
			for (Member data : datas) {
				result = data.toString() + "\n" + result;
			}
		}
		if (result.contains("\n")) {
			result = result.substring(0, result.length() - 1);
		}
		return result;
	}

	public Member(String data) {
		if (data != null && !data.isEmpty()) {
			if (data.contains("|")) {
				this.mID = data.split("\\|")[0];
				this.mName = data.split("\\|")[1];
			}
		}
	}

	@Override
	public int compareTo(Member another) {
		// TODO Auto-generated method stub
		String name1 = another.getName();
		if (name1.charAt(0) < mName.charAt(0)) {
			return 1;
		} else if (name1.charAt(0) > mName.charAt(0)) {
			return -1;
		} else {
			return 0;
		}
	}
}
